package com.atguigu.ForeachTest;

/**
 * @program: IDEAcode
 * @description:
 * @author: Mr.zjx
 * create: 2021-08-01-11-50
 **/
public class Test02 {
    public static void main(String[] args) {
        int sum = getSum(1,2,3,4,5,6);
        System.out.println(sum);
    }
    private static int getSum(int...a){
        //定义变量保存返回值
        int sum = 0;
        for (int i : a){ //a作为数组
            sum = sum + i;
        }
        return sum;
    }
}
